package geos;

import java.awt.Color;
import javax.swing.JOptionPane;
import org.apache.commons.validator.Validator;
import org.apache.commons.validator.routines.EmailValidator;

/**
 *
 * @author Suellen
 */
public class FrmCliente extends javax.swing.JInternalFrame {

    int cod_cliente, nr_cnpjcpf, nr_ierg;
    String nm_cliente, ds_email, nm_fantasia, ds_uf, ds_cidade, ds_bairro, ds_rua, ds_num, ds_complemento;
    boolean st_tipocliente = true;

    private void limpaCampos() {
        bairroTextField.setText("");
        cidadeTextField.setText("");
        cnpjcpfTextField.setText("");
        codigoTextField.setText("");
        complementoTextField.setText("");
        emailTextField.setText("");
        iergTextField.setText("");
        nomefantasiaTextField.setText("");
        numeroTextField.setText("");
        razaosocialTextField.setText("");
        ruaTextField.setText("");
        ufTextField.setText("");
    }

    private boolean validaCampos() {
        boolean valid = true;
        if (bairroTextField.getText().isEmpty()) {
            bairroTextField.setBackground(new Color(255, 100, 84));
            valid = false;
        }
        if (nomefantasiaTextField.getText().isEmpty()) {
            nomefantasiaTextField.setBackground(new Color(255, 100, 84));
            valid = false;
        }
        if (razaosocialTextField.getText().isEmpty()) {
            razaosocialTextField.setBackground(new Color(255, 100, 84));
            valid = false;
        }
        if (ufTextField.getText().isEmpty()) {
            ufTextField.setBackground(new Color(255, 100, 84));
            valid = false;
        }
        if (ruaTextField.getText().isEmpty()) {
            ruaTextField.setBackground(new Color(255, 100, 84));
            valid = false;
        }
        if (numeroTextField.getText().isEmpty()) {
            numeroTextField.setBackground(new Color(255, 100, 84));
            valid = false;
        }
        cnpjcpfTextField.getText();
        codigoTextField.getText();
        complementoTextField.getText();
        emailTextField.getText();
        iergTextField.getText();
        return valid;
    }

    /**
     * Creates new form Cliente
     */
    public FrmCliente() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuItem1 = new javax.swing.JMenuItem();
        jDesktopPane1 = new javax.swing.JDesktopPane();
        opcoesPanel = new javax.swing.JPanel();
        salvarButton = new javax.swing.JButton();
        excluirButton = new javax.swing.JButton();
        procurarButton = new javax.swing.JButton();
        sairButton = new javax.swing.JButton();
        principalPanel = new javax.swing.JPanel();
        codigoLabel = new javax.swing.JLabel();
        codigoTextField = new javax.swing.JTextField();
        razaosocialLabel = new javax.swing.JLabel();
        razaosocialTextField = new javax.swing.JTextField();
        nomefantasiaLabel = new javax.swing.JLabel();
        nomefantasiaTextField = new javax.swing.JTextField();
        tipopessoaLabel = new javax.swing.JLabel();
        tipopessoaComboBox = new javax.swing.JComboBox();
        cnpjcpfLabel = new javax.swing.JLabel();
        cnpjcpfTextField = new javax.swing.JTextField();
        iergLabel = new javax.swing.JLabel();
        iergTextField = new javax.swing.JTextField();
        telefoneButton = new javax.swing.JButton();
        emailLabel = new javax.swing.JLabel();
        emailTextField = new javax.swing.JTextField();
        enderecoPanel = new javax.swing.JPanel();
        ufLabel = new javax.swing.JLabel();
        ufTextField = new javax.swing.JTextField();
        cidadeLabel = new javax.swing.JLabel();
        cidadeTextField = new javax.swing.JTextField();
        bairroLabel = new javax.swing.JLabel();
        bairroTextField = new javax.swing.JTextField();
        numeroLabel = new javax.swing.JLabel();
        numeroTextField = new javax.swing.JTextField();
        ruaLabel = new javax.swing.JLabel();
        ruaTextField = new javax.swing.JTextField();
        complementoLabel = new javax.swing.JLabel();
        complementoTextField = new javax.swing.JTextField();

        jMenuItem1.setText("jMenuItem1");

        setTitle("Cliente");
        setToolTipText("");

        opcoesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        salvarButton.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        salvarButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GEOS/icones/16x16/disk.png"))); // NOI18N
        salvarButton.setText("Salvar");
        salvarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salvarButtonActionPerformed(evt);
            }
        });

        excluirButton.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        excluirButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GEOS/icones/16x16/bullet_cross.png"))); // NOI18N
        excluirButton.setText("Excluir");
        excluirButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                excluirButtonActionPerformed(evt);
            }
        });

        procurarButton.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        procurarButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GEOS/icones/16x16/bullet_magnify.png"))); // NOI18N
        procurarButton.setText("Procurar");

        sairButton.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        sairButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GEOS/icones/16x16/decline.png"))); // NOI18N
        sairButton.setText("Sair");

        javax.swing.GroupLayout opcoesPanelLayout = new javax.swing.GroupLayout(opcoesPanel);
        opcoesPanel.setLayout(opcoesPanelLayout);
        opcoesPanelLayout.setHorizontalGroup(
            opcoesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(opcoesPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(salvarButton)
                .addGap(18, 18, 18)
                .addComponent(excluirButton)
                .addGap(20, 20, 20)
                .addComponent(procurarButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(sairButton)
                .addContainerGap())
        );
        opcoesPanelLayout.setVerticalGroup(
            opcoesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(opcoesPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(opcoesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(salvarButton)
                    .addComponent(excluirButton)
                    .addComponent(procurarButton)
                    .addComponent(sairButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        principalPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Principal"));

        codigoLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        codigoLabel.setText("Cod:");

        codigoTextField.setEditable(false);
        codigoTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        razaosocialLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        razaosocialLabel.setText("Razão Social:");

        razaosocialTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        razaosocialTextField.setForeground(new java.awt.Color(255, 0, 102));

        nomefantasiaLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        nomefantasiaLabel.setText("Nome Fantasia:");

        nomefantasiaTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        tipopessoaLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        tipopessoaLabel.setText("Tipo Pessoa:");

        tipopessoaComboBox.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        tipopessoaComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        cnpjcpfLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        cnpjcpfLabel.setText("CNPJ / CPF:");

        cnpjcpfTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        iergLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        iergLabel.setText("IE/RG:");

        iergTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        telefoneButton.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        telefoneButton.setText("Telefone");

        emailLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        emailLabel.setText("E-mail:");

        emailTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        javax.swing.GroupLayout principalPanelLayout = new javax.swing.GroupLayout(principalPanel);
        principalPanel.setLayout(principalPanelLayout);
        principalPanelLayout.setHorizontalGroup(
            principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(principalPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(principalPanelLayout.createSequentialGroup()
                        .addGroup(principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(codigoTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(codigoLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(razaosocialTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(razaosocialLabel))
                        .addGap(18, 18, 18)
                        .addGroup(principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(nomefantasiaLabel)
                            .addComponent(nomefantasiaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 281, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tipopessoaLabel)
                            .addComponent(tipopessoaComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(principalPanelLayout.createSequentialGroup()
                        .addGroup(principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cnpjcpfTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cnpjcpfLabel))
                        .addGap(18, 18, 18)
                        .addGroup(principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(principalPanelLayout.createSequentialGroup()
                                .addComponent(iergLabel)
                                .addGap(182, 182, 182)
                                .addComponent(emailLabel))
                            .addGroup(principalPanelLayout.createSequentialGroup()
                                .addComponent(iergTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(26, 26, 26)
                                .addComponent(telefoneButton)
                                .addGap(18, 18, 18)
                                .addComponent(emailTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 281, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        principalPanelLayout.setVerticalGroup(
            principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(principalPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(principalPanelLayout.createSequentialGroup()
                        .addGroup(principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(codigoLabel)
                            .addComponent(razaosocialLabel)
                            .addComponent(nomefantasiaLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(codigoTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(razaosocialTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(nomefantasiaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(principalPanelLayout.createSequentialGroup()
                        .addComponent(tipopessoaLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tipopessoaComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cnpjcpfLabel)
                    .addComponent(iergLabel)
                    .addComponent(emailLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cnpjcpfTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(iergTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(telefoneButton)
                    .addComponent(emailTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        enderecoPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Endereço"));

        ufLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        ufLabel.setText("UF:");

        ufTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        cidadeLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        cidadeLabel.setText("Cidade:");

        cidadeTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        bairroLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        bairroLabel.setText("Bairro:");

        bairroTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        numeroLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        numeroLabel.setText("Número:");

        numeroTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        ruaLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        ruaLabel.setText("Rua:");

        ruaTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        complementoLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        complementoLabel.setText("Complemento:");

        complementoTextField.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        javax.swing.GroupLayout enderecoPanelLayout = new javax.swing.GroupLayout(enderecoPanel);
        enderecoPanel.setLayout(enderecoPanelLayout);
        enderecoPanelLayout.setHorizontalGroup(
            enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(enderecoPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(enderecoPanelLayout.createSequentialGroup()
                        .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ufTextField)
                            .addGroup(enderecoPanelLayout.createSequentialGroup()
                                .addComponent(ufLabel)
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cidadeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cidadeLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(bairroLabel)
                            .addComponent(bairroTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(enderecoPanelLayout.createSequentialGroup()
                        .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(numeroLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(numeroTextField))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ruaLabel)
                            .addComponent(ruaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(complementoLabel)
                            .addComponent(complementoTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(196, 196, 196))
        );
        enderecoPanelLayout.setVerticalGroup(
            enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(enderecoPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(enderecoPanelLayout.createSequentialGroup()
                        .addComponent(bairroLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bairroTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(enderecoPanelLayout.createSequentialGroup()
                        .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ufLabel)
                            .addComponent(cidadeLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ufTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cidadeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(enderecoPanelLayout.createSequentialGroup()
                        .addComponent(complementoLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(complementoTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(enderecoPanelLayout.createSequentialGroup()
                        .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(numeroLabel)
                            .addComponent(ruaLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(enderecoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(numeroTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ruaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(opcoesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(principalPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(enderecoPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 164, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(opcoesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(principalPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(enderecoPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(81, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void salvarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarButtonActionPerformed
        ds_bairro = bairroTextField.getText();
        ds_cidade = cidadeTextField.getText();
        nr_cnpjcpf = Integer.parseInt(cnpjcpfTextField.getText());
        // codigoTextField.getText();
        ds_complemento = complementoTextField.getText();
        ds_email = emailTextField.getText();
        nr_ierg = Integer.parseInt(iergTextField.getText());
        nm_fantasia = nomefantasiaTextField.getText();
        ds_num = numeroTextField.getText();
        nm_cliente = razaosocialTextField.getText();
        ds_rua = ruaTextField.getText();
        ds_uf = ufTextField.getText();
        if (validaCampos()) {
            DAOCliente cliente = new DAOCliente(0, nr_cnpjcpf, nr_ierg, st_tipocliente, nm_cliente, ds_email, nm_fantasia, ds_uf, ds_cidade, ds_bairro, ds_rua, ds_num, ds_complemento);
            if (cliente.InsertCliente()) {
                JOptionPane.showMessageDialog(rootPane, "Inserido com sucesso!");
            } else {
                JOptionPane.showMessageDialog(rootPane, "Erro ao inserir!");
            }
        }
    }//GEN-LAST:event_salvarButtonActionPerformed

    private void excluirButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_excluirButtonActionPerformed
        validaCampos();
        EmailValidator emailvalid = EmailValidator.getInstance();
        if (emailvalid.isValid(emailTextField.getText())) {
            emailTextField.setBackground(new Color(255, 255, 255));
        } else {
            emailTextField.setBackground(new Color(255, 100, 84));
            //JOptionPane.showMessageDialog(rootPane, "Inválido");
        }
    }//GEN-LAST:event_excluirButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel bairroLabel;
    private javax.swing.JTextField bairroTextField;
    private javax.swing.JLabel cidadeLabel;
    private javax.swing.JTextField cidadeTextField;
    private javax.swing.JLabel cnpjcpfLabel;
    private javax.swing.JTextField cnpjcpfTextField;
    private javax.swing.JLabel codigoLabel;
    private javax.swing.JTextField codigoTextField;
    private javax.swing.JLabel complementoLabel;
    private javax.swing.JTextField complementoTextField;
    private javax.swing.JLabel emailLabel;
    private javax.swing.JTextField emailTextField;
    private javax.swing.JPanel enderecoPanel;
    private javax.swing.JButton excluirButton;
    private javax.swing.JLabel iergLabel;
    private javax.swing.JTextField iergTextField;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JLabel nomefantasiaLabel;
    private javax.swing.JTextField nomefantasiaTextField;
    private javax.swing.JLabel numeroLabel;
    private javax.swing.JTextField numeroTextField;
    private javax.swing.JPanel opcoesPanel;
    private javax.swing.JPanel principalPanel;
    private javax.swing.JButton procurarButton;
    private javax.swing.JLabel razaosocialLabel;
    private javax.swing.JTextField razaosocialTextField;
    private javax.swing.JLabel ruaLabel;
    private javax.swing.JTextField ruaTextField;
    private javax.swing.JButton sairButton;
    private javax.swing.JButton salvarButton;
    private javax.swing.JButton telefoneButton;
    private javax.swing.JComboBox tipopessoaComboBox;
    private javax.swing.JLabel tipopessoaLabel;
    private javax.swing.JLabel ufLabel;
    private javax.swing.JTextField ufTextField;
    // End of variables declaration//GEN-END:variables
}
